package com.zyyx.course_manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zyyx.common.annotation.Log;
import com.zyyx.common.core.controller.BaseController;
import com.zyyx.common.core.domain.AjaxResult;
import com.zyyx.common.enums.BusinessType;
import com.zyyx.course_manage.domain.CourseManage;
import com.zyyx.course_manage.service.ICourseManageService;
import com.zyyx.common.utils.poi.ExcelUtil;
import com.zyyx.common.core.page.TableDataInfo;

/**
 * course_manageController
 * 
 * @author 张子航
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/course_manage/course_manage")
public class CourseManageController extends BaseController
{
    @Autowired
    private ICourseManageService courseManageService;

    /**
     * 查询course_manage列表
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CourseManage courseManage)
    {
        startPage();
        List<CourseManage> list = courseManageService.selectCourseManageList(courseManage);
        return getDataTable(list);
    }

    /**
     * 导出course_manage列表
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:export')")
    @Log(title = "course_manage", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseManage courseManage)
    {
        List<CourseManage> list = courseManageService.selectCourseManageList(courseManage);
        ExcelUtil<CourseManage> util = new ExcelUtil<CourseManage>(CourseManage.class);
        util.exportExcel(response, list, "course_manage数据");
    }

    /**
     * 获取course_manage详细信息
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:query')")
    @GetMapping(value = "/{courseManageId}")
    public AjaxResult getInfo(@PathVariable("courseManageId") Long courseManageId)
    {
        return success(courseManageService.selectCourseManageByCourseManageId(courseManageId));
    }

    /**
     * 新增course_manage
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:add')")
    @Log(title = "course_manage", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseManage courseManage)
    {
        return toAjax(courseManageService.insertCourseManage(courseManage));
    }

    /**
     * 修改course_manage
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:edit')")
    @Log(title = "course_manage", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseManage courseManage)
    {
        return toAjax(courseManageService.updateCourseManage(courseManage));
    }

    /**
     * 删除course_manage
     */
    @PreAuthorize("@ss.hasPermi('course_manage:course_manage:remove')")
    @Log(title = "course_manage", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseManageIds}")
    public AjaxResult remove(@PathVariable Long[] courseManageIds)
    {
        return toAjax(courseManageService.deleteCourseManageByCourseManageIds(courseManageIds));
    }
}
